<?php

namespace app\batch;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\Debug;
use app\models\{Order, BusinessArea, Agent, AgentArea, Config};
use think\Db;
use think\facade\Log;

class Jsjs extends Command
{
    protected $open = false;
    protected function configure()
    {
        $this->setName('Jsjs')->setDescription('插入数据');
    }

    protected function execute(Input $input, Output $output)
    {
        $this->doCron();
        die();
    }

    protected function doCron()
    {
        ini_set('max_execution_time', 0);
        $data = [];
        $data2 = [];
        Debug::remark('begin');
        for ($i = 0; $i < 10000000; $i++) {
            $data[] = [
                'type' => 3,
                'province' => 110000,
                'city' => 110100,
                'area' => 110108,
                'street' => 0,
                'businessid' => 2
            ];
            //(new BusinessArea())->save($dd);
            // (new AgentArea())->save(
            //     [
            //         'type' => 3,
            //         'province' => 110000,
            //         'city' => 110100,
            //         'area' => 110108,
            //         'street' => 0,
            //         'businessid' => 2
            //     ]
            // );
        }
        Debug::remark('end');
        //(new BusinessArea())->saveAll($data);
        echo Debug::getRangeTime('begin', 'end') . 's';
        Debug::remark('1begin');
        foreach ($data as $k => $v) {
            $data2[] = [
                'type' => 3,
                'province' => 110000,
                'city' => 110100,
                'area' => 110108,
                'street' => 0,
                'businessid' => 2
            ];
        }
        Debug::remark('1end');
        echo Debug::getRangeTime('1begin', '1end') . 's';
    }
}
